package com.cheng.service.system.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.cheng.dao.system.PermissionDao;
import com.cheng.domain.system.Permission;
import com.cheng.domain.system.User;

@Service
@Transactional
public class PermissionServiceImpl implements com.cheng.service.system.PermissionService {
	
	@Autowired
	private PermissionDao permissionDao;

	@Override
	public List<Permission> findByUser(User user) {
		if ("admin".equals(user.getUsername())) {
			return permissionDao.findAll();
		}
		return permissionDao.findByUser(user.getId());
	}

	@Override
	public List<Permission> findAll() {
		return permissionDao.findAll();
	}

	@Override
	public void save(Permission model) {
		permissionDao.save(model);
	}

}
